﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RestSharp;
using Ymatou.API.Common;
using Ymatou.ServiceCenter;
using YmatouSeller.NoticeAPI.Model.Entity;
using YmatouSeller.NoticeAPI.Model.Response;

namespace YmatouSeller.NoticeAPI.Model.Request
{
    [Resource("sellernotice.iapi.ymatou.com", "api/NoticeManage/SaveSystemNotice", Method.POST, ParameterBuildType.Json)]
    public class SaveSystemNoticeRequest : BaseRequestModel<SaveSystemNoticeResponse>
    {
        public override string ApiName
        {
            get { return "api/NoticeManage/SaveSystemNotice"; }
        }

        public override bool HttpGet
        {
            get { return false; }
        }

        public SystemNoticeDetail SystemNoticeDetail { get; set; }

        public override void Validate()
        {
            const string errCode = "-1";
            if (SystemNoticeDetail == null)
                throw new Ymatou.API.Common.BussniessException(errCode, "保存通知信息不能为空");
            if (string.IsNullOrEmpty(SystemNoticeDetail.NoticeTitle) || string.IsNullOrEmpty(SystemNoticeDetail.NoticeTitle.Trim()))
                throw new Ymatou.API.Common.BussniessException(errCode, "通知标题不能为空");
            if (string.IsNullOrEmpty(SystemNoticeDetail.NoticeContext) || string.IsNullOrEmpty(SystemNoticeDetail.NoticeContext.Trim()))
                throw new Ymatou.API.Common.BussniessException(errCode, "通知内容不能为空");
            if (SystemNoticeDetail.NoticeType <= 0)
                throw new Ymatou.API.Common.BussniessException(errCode, "通知类型不能为空");
            if (SystemNoticeDetail.TargetList == null || SystemNoticeDetail.TargetList.Count <= 0)
                throw new Ymatou.API.Common.BussniessException(errCode, "通知对象不能为空");

            base.Validate();
        }
    }
}
